package clone;

import person.ShallowPerson;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 38917
 * Date: 2025/5/11
 * Time: 01:40
 */

public class ShallowClone {
    //浅拷贝
    public static void main(String[] args) throws CloneNotSupportedException {
        ShallowPerson person1 = new ShallowPerson("张三",18,98);
        ShallowPerson person2 = (ShallowPerson) person1.clone();
        System.out.println(person1);
        System.out.println(person2);
        //修改person2的age
        person2.age = 20;
        System.out.println(person1);
        System.out.println(person2);
    }
}
